home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 5 / Apprentice-Release5.iso / Source Code / C++ / Applications / PICSee Dust 1.01 / Quaternary Source / GrayDraw 3D.cpp < prev    next >
C/C++ Source or Header  |  1995-11-16  |  4KB  |  150 lines

  1. #include "GrayDraw 3D.h"
  2.  
  3.  
  4. enum {
  5.     kBackgroundGrayRGB = 52428,
  6.     kDarkGrayRGB = 39321,
  7.     kDarkestGrayRGB = 17476, //21845,
  8.     
  9.     kWhiteRGB = 65535,
  10.     kBlackRGB = 0
  11. };
  12.  
  13.  
  14. // Needs to be fixed: may draw outside of bounding boxRect!
  15. void GrayDrawBox(short inset, const Rect *boxRect, const GrayDrawInfoPtr grayInfo) {
  16.     RGBColor bgGray, darkGray, darkestGray;
  17.     RGBColor white;
  18.     RGBColor saveFore, saveBack;
  19.     
  20.     GetForeColor(&saveFore);
  21.     GetBackColor(&saveBack);
  22.  
  23.     if (grayInfo != NULL) {
  24.         bgGray = grayInfo->bgGray;
  25.         darkGray = grayInfo->darkGray;
  26.         darkestGray = grayInfo->darkestGray;
  27.     }
  28.     else {
  29.         bgGray.red = bgGray.green = bgGray.blue = kBackgroundGrayRGB;
  30.         darkGray.red = darkGray.green = darkGray.blue = kDarkGrayRGB;
  31.         darkestGray.red = darkestGray.green = darkestGray.blue = kDarkestGrayRGB;
  32.     }
  33.  
  34.     white.red = white.green = white.blue = kWhiteRGB;
  35.  
  36.     RGBForeColor(&bgGray);
  37.     //PaintRect(boxRect);
  38.  
  39.     if (inset)
  40.         RGBForeColor(&darkestGray);
  41.     else
  42.         RGBForeColor(&white);
  43.     // Draw outer top line
  44.     MoveTo(boxRect->left, boxRect->top);
  45.     LineTo(boxRect->right, boxRect->top);
  46.     // Draw outer left line
  47.     MoveTo(boxRect->left, boxRect->top);
  48.     LineTo(boxRect->left, boxRect->bottom);
  49.     
  50.     if (inset)
  51.         RGBForeColor(&darkGray);
  52.     else
  53.         RGBForeColor(&white);
  54.     // Draw inner top line
  55.     MoveTo(boxRect->left+1, boxRect->top+1);
  56.     LineTo(boxRect->right-1, boxRect->top+1);
  57.     // Draw inner left line
  58.     MoveTo(boxRect->left+1, boxRect->top+1);
  59.     LineTo(boxRect->left+1, boxRect->bottom-1);
  60.     
  61.     if (inset)
  62.         RGBForeColor(&white);
  63.     else
  64.         RGBForeColor(&darkestGray);
  65.     // Draw outer right line
  66.     MoveTo(boxRect->right, boxRect->top+1);
  67.     LineTo(boxRect->right, boxRect->bottom);
  68.     // Draw outer bottom line
  69.     MoveTo(boxRect->left+1, boxRect->bottom);
  70.     LineTo(boxRect->right, boxRect->bottom);
  71.     
  72.     if (inset)
  73.         RGBForeColor(&white);
  74.     else
  75.         RGBForeColor(&darkGray);
  76.     // Draw inner right line
  77.     MoveTo(boxRect->right-1, boxRect->top+2);
  78.     LineTo(boxRect->right-1, boxRect->bottom-1);
  79.     // Draw inner bottom line
  80.     MoveTo(boxRect->left+2, boxRect->bottom-1);
  81.     LineTo(boxRect->right-2, boxRect->bottom-1);
  82.     
  83.     RGBForeColor(&saveFore);
  84.     RGBBackColor(&saveBack);
  85. } // END GrayDrawBox
  86.  
  87. // ---------------------------------------------------------------------------
  88.  
  89. void GrayDrawShadowLine(const Rect *lineRect, const GrayDrawInfoPtr grayInfo) {
  90.     RGBColor darkestGray;
  91.     RGBColor white;
  92.     RGBColor saveFore, saveBack;
  93.     Rect shadowRect;
  94.     
  95.     GetForeColor(&saveFore);
  96.     GetBackColor(&saveBack);
  97.  
  98.     if (grayInfo != NULL) {
  99.         darkestGray = grayInfo->darkestGray;
  100.     }
  101.     else {
  102.         darkestGray.red = darkestGray.green = darkestGray.blue = kDarkestGrayRGB;
  103.     }
  104.  
  105.     white.red = white.green = white.blue = kWhiteRGB;
  106.  
  107.     RGBForeColor(&darkestGray);
  108.     FrameRect(lineRect);
  109.     
  110.     shadowRect = *lineRect;
  111.     if ((lineRect->right - lineRect->left) > (lineRect->bottom - lineRect->top))
  112.         OffsetRect(&shadowRect, 0, 1);
  113.     else
  114.         OffsetRect(&shadowRect, 1, 0);
  115.     RGBForeColor(&white);
  116.     FrameRect(&shadowRect);
  117.  
  118.     RGBForeColor(&saveFore);
  119.     RGBBackColor(&saveBack);
  120. } // END GrayDrawShadowLine
  121.  
  122. // ---------------------------------------------------------------------------
  123.  
  124. void GrayDrawShadowBox(const Rect *boxRect, const GrayDrawInfoPtr grayInfo) {
  125.     Rect lineRect;
  126.     
  127.     // Left line
  128.     lineRect = *boxRect;
  129.     lineRect.right = lineRect.left + 1;
  130.     GrayDrawShadowLine(&lineRect, grayInfo);
  131.     
  132.     // Top line
  133.     lineRect = *boxRect;
  134.     lineRect.bottom = lineRect.top + 1;
  135.     lineRect.left++;
  136.     GrayDrawShadowLine(&lineRect, grayInfo);
  137.     
  138.     // Right line
  139.     lineRect = *boxRect;
  140.     lineRect.left = lineRect.right - 1;
  141.     OffsetRect(&lineRect, -1, 0);
  142.     GrayDrawShadowLine(&lineRect, grayInfo);
  143.     
  144.     // Bottom line
  145.     lineRect = *boxRect;
  146.     lineRect.top = lineRect.bottom - 1;
  147.     lineRect.right--;
  148.     OffsetRect(&lineRect, 0, -1);
  149.     GrayDrawShadowLine(&lineRect, grayInfo);
  150. } // END GrayDrawShadowBox